import {
  observable,
  autorun,
  when,
  action,
  makeAutoObservable,
  makeObservable,
  runInAction,
  computed,
  trace,
  getDependencyTree,
  toJS,
  get,
  set,
} from "mobx";

class Message {
  title;
  author;
  likes;
  constructor(title, author = { name: 123 }, likes = []) {
    makeObservable(this, {
      title: observable,
      author: observable,
      likes: observable,
      updateTitle: action,
    });
    this.title = title;
    this.author = author;
    this.likes = likes;
  }

  updateTitle(title) {
    this.title = title;
  }
}

const message = new Message("Foo", { name: "zhangqi" }, ["liuyue"]);

autorun(() => {
  console.log(JSON.stringify(message));
});

message.updateTitle("123");
